<%@page import="com.kaishengit.entity.Prod"%>
<%@page import="com.kaishengit.dao.ProdDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.kaishengit.entity.User"%>
<%@ page import="com.kaishengit.dao.UserDao"%>
<%
	//1.获取表单中用户输入的数据
	String name = request.getParameter("username");
	String pwd = request.getParameter("password");
	//服务端的验证
	if(name == null || pwd == null) {
		response.sendRedirect("index.jsp");
		return;
	}

	System.out.println("Name:" + name + "\tpwd:" + pwd);
	
	//2.验证用户名和密码是否正确
	UserDao dao = new UserDao();
	User user = dao.findByNameAndPwd(name, pwd);
	if(user != null) {
		//suc
		
		session.setAttribute("user", user);
		response.sendRedirect("home.jsp");
		
		//ProdDao prodDao = new ProdDao();
		//List<Prod> prodList = prodDao.findAll();
		
		//request.setAttribute("prodList", prodList);
		//request.setAttribute("myuser", user);
		//request.getRequestDispatcher("main.jsp").forward(request, response);
		
		//RequestDispatcher rd = request.getRequestDispatcher("main.jsp");
		//rd.forward(request, response);
		
	} else {
		//error
		response.sendRedirect("index.jsp?code=10001");
	}
%>








